package utils;

import java.util.ArrayList;

public class Node {
	public int ID;
	public String label;
	public Node parent;
	public ArrayList<Node> children;
	public int attribute;
	
	public Node(int iD, String label, Node parent, ArrayList<Node> children) {
		ID = iD;
		this.label = label;
		this.parent = parent;
		if (children == null)
			this.children = new ArrayList<Node>();
		else this.children = children;
		attribute = Multiplicity.NONE;
	}
	
	@Override
	public boolean equals(Object obj) {
		Node objnode = (Node)obj;
		return ID == objnode.ID;
	}
	
	@Override
	public String toString() {
		return "(" + label + ", " + ID + ")"; 
	}
	
	@Override
	protected Object clone() throws CloneNotSupportedException {
		@SuppressWarnings("unchecked")
		ArrayList<Node> cclone = (children.size() == 0)?(ArrayList<Node>)children.clone():null;
		Node pclone = (parent != null)?(Node)parent.clone():null;
		return new Node(ID, label, pclone, cclone);
	}

}
